package stockPrice;



import exceptions.WrongShareName;
import mainBoerse.Share;


public class RandomStockPriceProvider extends StockPriceProvider {
	
	/**
	 */
	private final double MIN_VALUE = 1;
	/**
	 */
	private final double MAX_VALUE = 10;

	
	

	@Override
	public void updateShareRates() {
		//update randomly all courses of all shares
		
		
		for(int i = 0; i < StockPriceProvider.getSHARES().size(); i++) {
			float new_course = (long)(MIN_VALUE + (Math.random() * (MAX_VALUE - MIN_VALUE) +1) + MIN_VALUE);
			StockPriceProvider.getSHARES().get(i).setCourse(new_course);
		}
		
	}

	@Override
	public void updateShareRate(Share share) throws WrongShareName {
		//TODO update only the course of one share 
		float new_course = (long)(MIN_VALUE + (Math.random() * (MAX_VALUE - MIN_VALUE) +1) + MIN_VALUE);
		
	
		try{
			this.getShare(share.getAktienName()).setCourse(new_course);;
			
		} catch (WrongShareName e) {
			throw e;
		}
		
		
	}

}
